﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.Caching;
using System.Text;
using System.Threading.Tasks;

namespace MRSite.Cache
{
    public interface ICache : IDisposable
    {
        string Name { get; }

        object Get(string key, Func<string, object> func);

        Task<object> GetAsync(string key, Func<string, Task<object>> func);

        TimeSpan SlidingExpireTime { get; set; }

        TimeSpan? AbsoluteExpireTime { get; set; }

        void Remove(string key);

        Task RemoveAsync(string key);

        void Clear();

        Task ClearAsync();

        object GetOrDefault(string key);

        Task<object> GetOrDefaultAsync(string key);

        void Set(string key, object value, TimeSpan? slidingExpireTime = null, TimeSpan? absoluteExpireTime = null);

        Task SetAsync(string key, object value, TimeSpan? slidingExpireTime = null, TimeSpan? absoluteExpireTime = null);

        Collection<ChangeMonitor> ChangeMonitors { get; set; }
    }
}
